package cn.kbyue.security.http;

import cn.kbyue.security.utils.BizExceptionEnum;
import cn.kbyue.security.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Error 处理
 *
 * @author xl
 * @date 2020/4/25 13:59
 */
@Slf4j
@RestController
public class IErrorController implements ErrorController {

    @Override
    public String getErrorPath() {
        log.error(">>> 出现错误，重定向/error");
        return "/error";
    }

    @GetMapping("/error")
    public Result<Object> error() {
        return Result.error(BizExceptionEnum.Internal_Error);
    }
}
